package com.mariusz.data.rules;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.mariusz.data.DataContainer;
import com.mariusz.data.dto.Payment;
import com.mariusz.data.dto.Rentier;
import com.mariusz.utils.Formats;

public class PaymentExceededRule implements Rule {

	@Override
	public List<String> processMessages(DataContainer dt) {
		List<String> messages = new ArrayList<String>();
		Date d = new Date();
		
		for(Rentier r : dt.getRentiers()){
			
			for(Payment p : r.getPayments()){
				if(!p.isPaied()&& p.getPaymentDate().before(d)){
					messages.add("Tenant "+r.getName()+" have missed a payment (on:"+Formats.formatDate(p.getPaymentDate())+"), for details please call: "+r.getTelephone()+".");
					break;
				}
			}
		}
		
		
		return messages;
	}

}
